//剪刀=1 石头=2 布=3
#include<iostream>
#include<ctime>
using namespace std;
struct m { int a; int b;};//结构里的玩家 a,b;
int main() {
	m f;
	int u=0;
	srand((unsigned int)time(NULL));//随机种子
	double c=0,z = 0,y=0,at=0;
	cout << "模拟玩家输出:\n";
	for (int d = 0; d <= 10000; d++) {
		f.a = rand() % 3+1;
		f.b = rand() % 3+1;
		at++;
		if (d % 10 == 2) {
			cout<<"GPL3.0!"<<endl;
			cout<<"GPL3.0!"<<endl;
			cout<<"GPL3.0!"<<endl;;
		}
		if (f.a == 1&&f.b==3) {//A出1	
			cout << "A玩家获胜" << ",A出了剪刀 B出了布" << endl;
			cout << "=====================================" << endl;
			c++;
		}
		if (f.a == 2 && f.b == 3) {//特殊情况 A出2
			cout << "A玩家获胜" << ",A出了石头 B出了布" << endl;
			cout << "=====================================" << endl;
			c++;
		}
		if (f.a == 3 && f.b == 1) {
			cout << "A玩家获胜" << ",A出了布 B出了石头" << endl;
			cout << "=====================================" << endl;
			c++;
		}
		//B玩家-------------------------------------------------
		if (f.b == 1&&f.a==3) {//A出1
			cout << "B玩家获胜" << ",B出了剪刀 A出了布" << endl;
			cout << "=====================================" << endl;
			z++;
		}
		if (f.b == 2 && f.a == 3) {//特殊情况 A出2
			cout << "B玩家获胜" << ",B出了石头 A出了布" << endl;
			cout << "=====================================" << endl;
			z++;
		}
		if (f.b == 3 && f.a == 1) {
			cout << "B玩家获胜" << ",B出了布 A出了石头" << endl;
			cout << "=====================================" << endl;
			z++;
		}
		//平局
		if (f.a == f.b) {
			y++;
		}
	}
	cout << "\n\n\n**************************************\n";
	cout << "*------------------------------------*\n";
	cout << "*==============统计信息==============*\n";
	cout << "*========A玩家共计获胜：" << c << "次========*" << endl;
	cout << "*========B玩家共计获胜：" << z << "次========*" << endl;
	cout << "*======本次对弈共计平局：" << y << "次=======*" << endl;
	cout << "*------------------------------------*\n";
	cout << "**************************************\n";
	//胜率计算
	double aat = at - c, bt = at - z;
	cout << "终于经过" << at << "次模拟得出:";
	cout << "A胜率" << 1 - (aat / at);
	cout << " B胜率" << 1 - (bt / at) << endl;
	cout << "所以综上所述:理论上玩石头剪刀布的时候 只要出的随机 那么获胜概率是一样的。\n\n\n\n";
	cout << "作者:子立先生 昵称:花粉 创作时间:2021年7月15日 B站UID:399313598.\n\n\n" << endl;
	cin.get();//停留 显示结果
	return 0;
}